//this is just a test class until I can connect to the DB
package edu.unc.comp410.colemangeer.data;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;

import com.mysql.jdbc.CommunicationsException;

import edu.unc.comp410.colemangeer.model.Product;


public class ProdGateTest {
	//Error message catalog
	//private static final String CUSTOMER_ZIP_NOT_IN_FILE = "Zip Code not in zip table for customer:\n\t";
	//private static final String CITY_STATE_MISMATCH = "City/State mismatch in zip table for customer:\n\t";
	
	// Data access objects
	//private ZipGatewayEmulator zipEmulator;
	//private CustomerGatewayEmulator customerEmulator;
	private IProductGateway productEmulator;
	private IProductGateway productGateway;
	
	// Customers for validation
	List<Product> ProductsToCheck;

	
	// custom view of zip code list, associating a zipcode with a set of (city, state) values
	// this structure can handle a one-to-many relationship between zipcode and (city, state),
	// which doesn't seem to ever occur in the input data we were given
	//Map<String,Set<OrderedPair<String,String>>> zipCodeToCityStateMap;
	
	/**
	 * Default constructor
	 */
	public ProdGateTest(){
		ProductsToCheck = new ArrayList<Product>();
	}
	
	
	public static void main(String[] args) {
		ProdGateTest validator =  new ProdGateTest();
		
		try {
			validator.initProductList(); 
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		//validator.initZipCityStateMap();	
	}
	
	/**
	 * Initialize list of customer objects
	 * @throws FileNotFoundException
	 * @ensures a package-visible hashmap called prodTable is loaded with products
	 * 
	 * creates an emulator object, 
	 * which calls loadFromFile(),
	 * which puts product objects into a package-visible 
	 * hashmap called prodTable
	 */
	public void initProductList() throws FileNotFoundException, CommunicationsException{

		try {
			productEmulator = new ProductGateway("customer1","classroom");
		} catch (Exception e) {
			productEmulator = new ProductGatewayEmulator();
			e.printStackTrace();
		}
		
		
		//customersToCheck.addAll(customerEmulator.custTable.values());
	}

	/**
	 * check for customer zipcode in zip table
	 * if it is there, check integrity of customer city/state values
	 * if not there, report error
	 */
	/*private void validateCustomerZipCodes(){		
		for (Customer c: customersToCheck){
			if (!zipCodeToCityStateMap.containsKey(c.getZipCode())){
				System.out.println(CUSTOMER_ZIP_NOT_IN_FILE + c.toString());
			}
			else{
				validateCityAndStateIntegrity(c);
			}
		}
	}*/
	
	/** 
	 * check for integrity of customer city/state values
     *  if they don't match the zip table's values, report error
	 */
	/*private void validateCityAndStateIntegrity(Customer c){
		
		Set<OrderedPair<String,String>> correctCityStateSet;
		correctCityStateSet = this.zipCodeToCityStateMap.get(c.getZipCode());
		OrderedPair<String,String> customerVals = new OrderedPair<String,String>(c.getCity(),c.getStateAbbrev());
		if (!correctCityStateSet.contains(customerVals)){
			System.out.println(CITY_STATE_MISMATCH + c.toString());
		}
	}*/
	
	

}
